<template>
  <div id="hostPerformance" >
    <!--右上角按钮-->
    <div style='position:absolute;right:2%;top:10%;z-index: 99'>
      <div class='top_button_box'>
        <!--
        <el-date-picker
          v-model="dateRange"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          >
        </el-date-picker>-->

        <el-switch style="margin-left: 5px"
          v-model="switchValue">
        </el-switch>
        <i style="margin-left:5px;color: white;font-size: 30px;opacity: 0.5;z-index: 98" @click="fullScreen" class="el-icon-full-screen"></i>
      </div>
    </div>


    <div id="entirety" style="background-image: url('/static/hostPerformance/背景.png')">

      <!--标题行-->
      <el-row>
        <div class="title_row">

          <div class='title_box'>
            <div class="title_box_text">
              主机性能监控
            </div>
            <div class="title_box_hr"></div>
          </div>

        </div>

      </el-row>
      <!-- 左侧 -->
      <el-row :gutter="30">
        <el-col :span="8">
          <!-- 主机CPU性能统计TOP5 -->
          <div>
            <div class='card_title_row'>
              <div class="title_class title_left_class">主机CPU性能统计TOP5</div>
              <el-radio-group v-model="cpuRadio" size="mini" @change='makeCpuChart'>
                <el-row :gutter='10'>
                  <el-col :span='8'><el-radio-button label="云主机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="物理机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="虚拟机"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div class='chart_box'>
              <div id="statistics_cpu" style="height: 27vh;">statistics_cpu</div>
            </div>
          </div>
          <!-- 主机内存性能统计TOP5 -->
          <div>
            <div class='card_title_row'>
              <div class="title_class title_left_class">主机内存性能统计TOP5</div>
              <el-radio-group v-model="memoryRadio" size="mini"  @change='makeMemoryChart'>
                <el-row :gutter='10'>
                  <el-col :span='8'><el-radio-button label="云主机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="物理机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="虚拟机"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div class='chart_box'>
              <div id="statistics_memory" style="height: 27vh;">statistics_memory</div>
            </div>
          </div>
          <!-- 主机磁盘性能统计TOP5 -->
          <div>
            <div class='card_title_row'>
              <div class="title_class title_left_class">主机磁盘性能统计TOP5</div>
              <el-radio-group v-model="diskRadio" size="mini"  @change='makeDiskChart'>
                <el-row :gutter='10'>
                  <el-col :span='8'><el-radio-button label="云主机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="物理机"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="虚拟机"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div class='chart_box'>
              <div id="statistics_disk" style="height: 27vh;">statistics_disk</div>
            </div>
          </div>
        </el-col>
        <!-- 中间部分 -->
        <el-col :span="8">
          <!-- 主机数 -->
          <el-row :gutter="20">
            <el-col :span="8">
              <div class="host_num_box">
                <span class='host_num_text' style='color:white'>主机总数</span>
                <span class='host_num_text' style='color:#C0C0C0'>{{hostNum}}</span>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="host_num_box">
                <span class='host_num_text' style='color:white'>正常主机数</span>
                <span class='host_num_text' style='color:#87CEFA'>{{normalHostNum}}</span>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="host_num_box">
                <span class='host_num_text' style='color:white'>异常主机数</span>
                <span class='host_num_text' style='color:red'>{{abnormalHostNum}}</span>
              </div>
            </el-col>
          </el-row>
          <!-- 8个box -->
          <div>
            <div>
              <div class="hr_tag"></div>
              <div class="hr hr_mid"></div>
              <div style="margin-left: -9px">
                <el-row>
                  <el-col v-for="(item,i) in gailan_box" :key="i" :span="6">
                    <div class="gailan_box">
                      <div class="gailan_box_center"><img class="gailan_box_img" :src='item.icon'></div>
                      <div>
                        <hr/>
                      </div>
                      <div class="gailan_box_center">
                        <span class="gailan_box_total" style="font-size: 23px;">{{ item.value }}</span>
                        <span v-if="item.total != null" class="gailan_box_total" style="font-size: 16px;">/{{
                            item.total
                          }}</span>
                      </div>
                      <div class="gailan_box_lable"  style="margin-top: 3vh;padding-bottom: 2vh;">
                        <div v-for="(label,i) in item.label" :key="i">{{ label }}</div>
                      </div>
                    </div>
                  </el-col>
                </el-row>
              </div>
            </div>
            <div style="margin-top: 2vh;">
              <div class="title_class">厂商资源统计TOP5</div>
              <div class="hr_tag"></div>
              <div class="hr hr_mid"></div>
              <div>
                <div id="manufacturer_chart" style="height: 27vh;">manufacturerChartData</div>
              </div>
            </div>
          </div>
        </el-col>
        <!--右侧-->
        <el-col :span="8" style='margin-left: -2%'>
          <!--异常数据统计-->
          <div>
            <div class='card_title_row'>
              <div class="title_class title_left_class">异常数据统计</div>
              <el-radio-group v-model="abnormalRadio" size="mini" @change='makePieChart'>
                <el-row :gutter='10'>
                  <el-col :span='8'><el-radio-button label="CPU"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="内存"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="磁盘"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div>
              <div id="abnormal_chart" style="height: 27vh;width:100%;margin-left: 3%">abnormal_chart_data</div>
            </div>
          </div>
          <!--资源告警数统计-->
          <div>
            <div class='card_title_row' >
              <div class="title_class title_left_class">资源告警数统计TOP5</div>
              <el-radio-group v-model="alarmRadio" size="mini" @change='getAlarmTableData'>
                <el-row :gutter='10'>
                  <el-col :span='6'><el-radio-button label="全部"></el-radio-button></el-col>
                  <el-col :span='6'><el-radio-button label="严重"></el-radio-button></el-col>
                  <el-col :span='6'><el-radio-button label="中等"></el-radio-button></el-col>
                  <el-col :span='6'><el-radio-button label="一般"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div style="height: 26vh;" class='table_box'>
              <el-table
                :data="alarmTableDataShow"
                :row-style="{height: '3.5vh'}"
                :cell-style="{padding: '0'}"
                :header-row-style="{height: '4vh'}"
                :header-cell-style="{padding: '0'}"
                style="width: 90%;margin-left: 10%;margin-top:5px">
                <el-table-column  label="等级">
                  <template slot-scope="scope">
                    {{getSeverityText(scope.row.severity)}}
                  </template>
                </el-table-column>
                <el-table-column prop="message" label="告警内容"  :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="host"  label="IP地址"></el-table-column>
                <el-table-column label="操作" align="center">
                  　<template slot-scope="scope">
                      <el-button slot="reference" size="mini" type="text" @click='openTableDetailDialog(scope.row)'>详情</el-button>
                  　</template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <!--资源告警数统计-->
          <div>
            <div class='card_title_row'>
              <div class="title_class title_left_class">云服务性能统计TOP5</div>
              <el-radio-group v-model="serviceRadio" size="mini" @change='makePerformenceChart'>
                <el-row :gutter='10'>
                  <el-col :span='8'><el-radio-button label="aaaa"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="bbbb"></el-radio-button></el-col>
                  <el-col :span='8'><el-radio-button label="cccc"></el-radio-button></el-col>
                </el-row>
              </el-radio-group>
            </div>
            <div class="hr_tag" style="margin-left: 50px;"></div>
            <div class="hr hr_left"></div>
            <div class='chart_box'>
              <div id="test" style="height: 27vh;">statistics_cpu</div>
            </div>
          </div>
        </el-col>
      </el-row>
      <!--折线图-->
      <el-dialog
        title=""
        :visible.sync="chartDialogVisible"
        width="50%"
      >
        <div ref='chartInDialog' style='margin:0px 20px 0px 20px;height: 60vh;width:90%'></div>
        <span slot="footer" class="dialog-footer">

      </span>
      </el-dialog>
      <!--饼图点击详情-->
      <el-dialog
        :title="pieChartDialogTitle"
        :visible.sync="pieChartDialogVisible"
        width="40%"
        style='margin-left:50%'
      >
        <div style='padding:20px;'>
          <div v-for="item in pieChartAbnormalList" :key='item.id' >
            <span>id:</span>
            <span>{{item.id}}</span>
            <span>{{item.message}}</span>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
      </span>
      </el-dialog>
      <!--Table详情-->
      <el-dialog
        :visible.sync="tableDetailDialogVisible"
        width="40%"
        style='margin-left:50%;margin-top:15vh'
      >
        <div style='padding:20px;'>
          <el-descriptions title="详情" :column="1">
            <el-descriptions-item label="等级">{{ getSeverityText(tableDetailMessage.severity) }}</el-descriptions-item>
            <el-descriptions-item label="告警内容">{{ tableDetailMessage.message }}</el-descriptions-item>
            <el-descriptions-item label="告警资源名称">{{ tableDetailMessage.messageName }}</el-descriptions-item>
            <el-descriptions-item label="IP地址">{{ tableDetailMessage.host }}</el-descriptions-item>
            <el-descriptions-item label="发生时间">{{ tableDetailMessage.firstTime }}</el-descriptions-item>
            <el-descriptions-item label="关闭时间">{{ tableDetailMessage.affirmedTime }}</el-descriptions-item>
          </el-descriptions>
        </div>
        <span slot="footer" class="dialog-footer">
      </span>
      </el-dialog>
    </div>

  </div>
</template>

<script src='./js/index.js'>
</script>
<style lang="scss">
@font-face {
  font-family: 'Alternate';
  //src: url('../../assets/iconfont/Alternate.ttf');
  font-style: normal;
  font-width: normal;
}

@import './css/hostPerformance.scss';
</style>
